'use strict';

/**
 * @ngdoc function
 * @name payPcApp.controller:AboutCtrl
 * @description
 * # AboutCtrl
 * Controller of the payPcApp
 */
angular.module('payPcApp')
    .controller('booksearchCtrl', function($scope, booksearch_model) {
        $scope.detail_panel = false;
        $scope.type = 'title';
        $scope.get_book = function(pageindex) {
            booksearch_model.getdata({
                type: $scope.type,
                condition: $scope.condition,
                pageindex: pageindex ? pageindex : 1
            }).success(function(response) {
                console.log(response);
                if (response.statusCode == '40005') {
                    $scope.book_list = true;
                    return;
                }
                $scope.book_list = response.list;
                if (response.page.currentPage == 1) {
                    response.page.firstPage = true;
                }
                if (response.page.currentPage == response.page.totalPage) {
                    response.page.lastPage = true;
                }
                response.page.now = response.page.currentPage;
                $scope.book_list_page = response.page;
                console.log($scope.book_list_page);
            })
        };
    });